<HTML
><HEAD
><TITLE
>Allocating disk space</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.63
"><LINK
REL="HOME"
TITLE="The Linux System Administrator's Guide"
HREF="index.html"><LINK
REL="UP"
TITLE="Using Disks and Other Storage Media"
HREF="c955.html"><LINK
REL="PREVIOUS"
TITLE="Disks without filesystems"
HREF="x1657.html"><LINK
REL="NEXT"
TITLE="Memory Management"
HREF="memory-management.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>The Linux System Administrator's Guide: Version 0.7</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x1657.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 6. Using Disks and Other Storage Media</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="memory-management.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN1675"
>6.10. Allocating disk space</A
></H1
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1677"
>6.10.1. Partitioning schemes</A
></H2
><P
>It is not easy to partition a disk in the best possible way.
	Worse, there is no universally correct way to do it; there are
	too many factors involved.</P
><P
>The traditional way is to have a (relatively) small
	root filesystem, which contains <TT
CLASS="FILENAME"
>/bin</TT
>,
	<TT
CLASS="FILENAME"
>/etc</TT
>, <TT
CLASS="FILENAME"
>/dev</TT
>,
	<TT
CLASS="FILENAME"
>/lib</TT
>, <TT
CLASS="FILENAME"
>/tmp</TT
>, and other
	stuff that is needed to get the system up and running.	This way,
	the root filesystem (in its own partition or on its own disk) is all
	that is needed to bring up the system.  The reasoning is that if the
	root filesystem is small and is not heavily used, it is less likely
	to become corrupt when the system crashes, and you will therefore
	find it easier to fix any problems caused by the crash.  Then you
	create separate partitions or use separate disks for the directory
	tree below <TT
CLASS="FILENAME"
>/usr</TT
>, the users' home directories
	(often under <TT
CLASS="FILENAME"
>/home</TT
>), and the swap space.
	Separating the home directories (with the users' files) in their own
	partition makes backups easier, since it is usually not necessary to
	backup programs (which reside below <TT
CLASS="FILENAME"
>/usr</TT
>).  In
	a networked environment it is also possible to share
	<TT
CLASS="FILENAME"
>/usr</TT
> among several machines (e.g., by using
	NFS), thereby reducing the total disk space required by several tens
	or hundreds of megabytes times
	the number of machines.</P
><P
>The problem with having many partitions is that it splits
	the total amount of free disk space into many small pieces.
	Nowadays, when disks and (hopefully) operating systems are more
	reliable, many people prefer to have just one partition that holds
	all their files.  On the other hand, it can be less
	painful to back up (and restore) a small partition.</P
><P
>For a small hard disk (assuming you don't do kernel
	development), the best way to go is probably to have just one
	partition.  For large hard disks, it is probably better to have a
	few large partitions, just in case something does go wrong.  (Note
	that `small' and `large' are used in a relative sense here; your
	needs for disk space
	decide what the threshold is.)</P
><P
>If you have several disks, you might wish to have the
	root filesystem (including <TT
CLASS="FILENAME"
>/usr</TT
>) on one,
	and the users' home directories on another.</P
><P
>It is a good idea to be prepared to experiment a bit
	with different partitioning schemes (over time, not just while first
	installing the system).  This is a bit of work, since it essentially
	requires you to install the system from scratch several times
		<A
NAME="AEN1695"
HREF="#FTN.AEN1695"
>[1]</A
>
	, but it is the only way to be sure you do
	it right.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1697"
>6.10.2. Space requirements</A
></H2
><P
>The Linux distribution you install will give some indication
	of how much disk space you need for various configurations. Programs
	installed separately may also do the same.  This will help you plan
	your disk space usage, but you should prepare for the future and
	reserve some extra space for things you will
	notice later that you need.</P
><P
>The amount you need for user files depends on what your
	users wish to do.  Most people seem to need as much space for their
	files as possible, but the amount they will live happily with varies
	a lot.  Some people do only light text processing and will survive
	nicely with a few megabytes, others do heavy
	image processing and will need gigabytes.</P
><P
>By the way, when comparing file sizes given in
	kilobytes or megabytes and disk space given in megabytes, it can be
	important to know that the two units can be different. Some disk
	manufacturers like to pretend that a kilobyte is 1000 bytes and a
	megabyte is 1000 kilobytes, while all the rest of the computing
	world uses 1024 for both factors.  Therefore, my 345 MB hard disk
	was really a 330 MB hard disk.</P
><P
>Swap space allocation is discussed in <A
HREF="swap-allocation.html"
>Section 7.5</A
>.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1704"
>6.10.3. Examples of hard disk allocation</A
></H2
><P
>I used to have a 109 MB hard disk.  Now I am using a 330 MB
	hard disk.  I'll explain how and why I partitioned those
	disks.</P
><P
>The 109 MB disk I partitioned in a lot of ways, when my
	needs and the operating systems I used changed; I'll explain
	two typical scenarios.	First, I used to run MS-DOS together
	with Linux.  For that, I needed about 20 MB of hard disk, or
	just enough to have MS-DOS, a C compiler, an editor, a few other
	utilities, the program I was working on, and enough free disk
	space to not feel claustrophobic.  For Linux, I had a 10 MB swap
	partition, and the rest, or 79 MB, was a single partition with all
	the files I had under Linux.  I experimented with having separate
	root, <TT
CLASS="FILENAME"
>/usr</TT
>, and <TT
CLASS="FILENAME"
>/home</TT
>
	partitions, but there was never enough free disk space in one
	piece to do much interesting.</P
><P
>When I didn't need MS-DOS anymore, I repartitioned the
	disk so that I had a 12 MB swap partition, and again had the
	rest as a single filesystem.</P
><P
>The 330 MB disk is partitioned into several partitions, like
	this:

		<DIV
CLASS="INFORMALTABLE"
><A
NAME="AEN1712"
></A
><P
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>5 MB</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>root filesystem</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
> 10 MB</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>swap partition</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>180 MB</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="FILENAME"
>/usr</TT
> 
		filesystem</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
>120 MB</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="FILENAME"
>/home</TT
> 
		filesystem</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
> 15 MB</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>scratch partition</TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
>

	The scratch partition is for playing around with things that
	require their own partition, e.g., trying different Linux
	distributions, or comparing speeds of filesystems.  When not
	needed for anything else, it is used as swap space (I like to
	have a lot of open windows).
	
		<A
NAME="AEN1732"
HREF="#FTN.AEN1732"
>[2]</A
>
	</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1734"
>6.10.4. Adding more disk space for Linux</A
></H2
><P
>Adding more disk space for Linux is easy, at least after the
	hardware has been properly installed  (the hardware installation
	is outside the scope of this book).  You format it if necessary,
	then create the partitions and filesystem as described above,
	and add the proper lines to <TT
CLASS="FILENAME"
>/etc/fstab</TT
>
	so that it is mounted automatically.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1738"
>6.10.5. Tips for saving disk space</A
></H2
><P
>The best tip for saving disk space is to avoid installing
	unnecessary programs.  Most Linux distributions have an
	option to install only part of the packages they contain,
	and by analysing your needs you might notice that you don't
	need most of them.  This will help save a lot of disk space,
	since many programs are quite large.  Even if you do need a
	particular package or program, you might not need all of it.
	For example, some on-line documentation might be unnecessary,
	as might some of the Elisp files for GNU Emacs, some of the
	fonts for X11, or some of the libraries for programming.</P
><P
>If you cannot uninstall packages, you might look into
	compression.  Compression programs such as <B
CLASS="COMMAND"
>gzip</B
>
	or <B
CLASS="COMMAND"
>zip</B
> will compress (and uncompress)
	individual files or groups of files.  The <B
CLASS="COMMAND"
>gzexe</B
>
	system will compress and uncompress programs invisibly to the
	user (unused programs are compressed, then uncompressed as they
	are used).  The experimental DouBle system will compress all
	files in a filesystem, invisibly to the programs that use them.
	(If you are familiar with products such as Stacker for MS-DOS 
	or DriveSpace for Windows, the principle is the same.)</P
></DIV
></DIV
><H3
CLASS="FOOTNOTES"
>Notes</H3
><TABLE
BORDER="0"
CLASS="FOOTNOTES"
WIDTH="100%"
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN1695"
HREF="x1675.html#AEN1695"
>[1]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>		This is not actually true, it is possible to move partitions
		and mountpoints without reinstalling, but it is (currently)
		beyond the scope of this book to explain how.  It is on the
		TODO list to write a section on this.  If you have
		experience and knowledge in this area then perhaps you could
		write it for me and save me the bother? :)
		</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN1732"
HREF="x1675.html#AEN1732"
>[2]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>This section is somewhat out of date.  Most people 
		these days have disks that stretch into the multiple
		Gigabytes.  It is still quite scalable (just multiply by
		some factor to make it fit your hardware) for the moment
		though, updating it to take
		account of larger disks is planned.</P
></TD
></TR
></TABLE
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x1657.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="memory-management.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Disks without filesystems</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c955.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Memory Management</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>